import { __http } from "sept-ui/lib/utils/communicate/index";
const ExeApi = (data, api) =>{
    //判断jwt是否超时
    let time = new Date().getTime();
    let outt = Number(localStorage.getItem('__jwtOuttime'));
    if((outt- time) < 0){
        //更新
        __http.request({
            url: `sa_UserLoginInAction_getRefreshToken.do`,
            method: "POST",
            data: { token: localStorage.getItem('__jwt') }
        }).then(res => {
            localStorage.setItem('__jwt', res?.data?.appdata?.token);
            localStorage.setItem('__jwtOuttime', res?.data?.appdata?.token_out_time);
        });
    }
    //防止后端偶尔报错
    data.submit_type = 1;
    return __http.request({
        url: `${api}?jwt=${localStorage.getItem('__jwt')}`,
        method: "POST",
        data
    });
    
}

export default ExeApi;
